Normalize whitespace and strip stray <br> tags in spreadsheet export (BL-16518)#8074
Normalize whitespace and strip stray <br> tags in spreadsheet export (BL-16518)#8074StephenMcConnel wants to merge 4 commits into
Conversation
|
| Filename | Overview |
|---|---|
| src/BloomExe/Spreadsheet/SpreadsheetExporter.cs | Adds targeted whitespace normalization after content extraction: replaces <br>/<br /> with a space, collapses ordinary whitespace runs with a regex that correctly excludes non-breaking spaces, then trims. Logic is correct and well-commented. |
| src/BloomTests/Spreadsheet/SpreadsheetAudioTests.cs | Adds a focused regression-test class covering split-TextBox and sentence-mode audio pages with <br> + multi-space boundaries; includes sanity-check assertions in OneTimeSetUp to prevent false passes. |
| src/BloomTests/Spreadsheet/SpreadsheetExporterTests.cs | Updates two existing assertions from double-space to single-space output and adds ExportNormalizesContent_SpacesOutLineBreaks_CollapsesWhitespace_PreservesNbsp covering all three normalization behaviours in one shot. |
Reviews (5): Last reviewed commit: "Add audio regression tests for line-brea..." | Re-trigger Greptile
|
[Claude Opus 4.8] Consulted Devin up to |
|
This is going to be REALLY slow... |
…(BL-16518) When exporting a book to a spreadsheet, each bloom-editable's content was written to the cell verbatim, so leading/trailing whitespace, stray <br> tags, and runs of whitespace leaked into the exported spreadsheet. Trim the content, remove <br>/<br /> tags (which should not be present), and collapse runs of whitespace to a single space so the exported text is normalized. Update SpreadsheetExporterTests expectations to the normalized (single-space) output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1233bb3 to
f07c8a0
Compare
|
[Claude Opus 4.8] Good call — the approach here has been changed to address exactly that concern. It no longer runs |
|
[Claude Opus 4.8] Consulted Devin on 2026-07-20 11:08 MDT up to commit Devin found 2 current bugs, both in
One Investigate flag ("diff doesn't match the ProcessBook description") was a false positive once the PR description was rewritten to match the new approach — replied and resolved. All other Devin items (the book-name-rename bug and the CI checks green; Greptile green. |
…in spreadsheet export (BL-16518) Address review findings (Devin, Greptile, and the preflight review) on the new export normalization: - Collapse only ordinary (breaking) whitespace instead of \s, so non-breaking spaces (U+00A0, U+202F, ...) are preserved rather than silently converted to ordinary spaces. These are meaningful, e.g. French punctuation spacing. - Replace <br>/<br /> with a single space rather than an empty string, so words on either side of a soft line break (Shift+Enter) are not run together. Add a test exercising all three normalization behaviors (line-break spacing, whitespace collapse, and non-breaking-space preservation). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
[Claude Opus 4.8] Consulted Devin on 2026-07-20 11:42 MDT up to commit |
… export (BL-16518) Closes the coverage gap identified in review: no test exercised audio-bearing content that contains a <br> between sentences (or runs of extra whitespace) through the exporter's normalization. If normalization fused two <br>-separated sentences (as the earlier <br>->"" code would have), the re-imported text would fragment into fewer sentences than there are recorded audio segments, dropping or desyncing the audio. Adds Spreadsheet_AudioWhitespaceNormalization_Tests covering both split-TextBox mode (two timed segments, endtimes preserved) and Sentence mode (one file per sentence), asserting the sentence boundary survives export as a single space and the segment/endtime/audio-file mapping stays intact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
[Claude Opus 4.8] Consulted Devin on 2026-07-20 14:40 MDT up to commit |
What
When exporting a book to a spreadsheet, each
bloom-editable's content was written to the cell verbatim (editable.InnerXml), so un-normalized text leaked into the exported spreadsheet: leading/trailing whitespace, stray<br>/<br />tags, and runs of multiple whitespace characters.Change
In
SpreadsheetExporter.WriteTranslationGroup, after extracting each editable's content (and converting the audio-split marker to|), the content is now normalized before being written to the cell:<br>/<br />tags (which should not be present in exported text);SpreadsheetExporterTestsexpectations were updated to the normalized (single-space) output.Testing
SpreadsheetExporterTests, round-trip, and general spreadsheet tests).Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16518
Devin review
This change is
Description updated by [Claude Opus 4.8] during preflight to reflect the current implementation.